package cn.com.headfree.mouldshow.dao.impl;

import cn.com.headfree.entity.TContestInfo;
import cn.com.headfree.mouldshow.dao.TContestInfoDao;
import cn.com.headfree.vo.simple.ContestInfoVo;
import com.gta.edu.sdk.base.dao.impl.BaseDaoImpl;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository("/tContestInfoDao")
public class TContestInfoDaoImpl extends BaseDaoImpl<TContestInfo> implements TContestInfoDao {


    @Override
    public List<ContestInfoVo> findByBaseorgId(String deptId) throws Exception{
        Object[] params = new Object[1];
//        StringBuilder sql = new StringBuilder("select t.id,t.erp_no,t.comp_name,t.host_org,GET_DIC('JygexinQcJb',t.award_level) as award_level,GET_DIC('JygexinQcDj',t.comp_rank) as comp_rank,t.get_title,t.award_date,DATE_FORMAT(t.award_date,'%Y-%m-%d %H:%i:%s') as award_date_str,u.xb_name as user_name from t_contest_info t INNER JOIN t_dept_emp_rela d on t.erp_no=d.erp_no INNER JOIN (select * from t_org_dept o where o.path like ?) o2 on o2.id=d.dept_id INNER JOIN t_isc_user_tmp u on t.erp_no=u.hr_erp WHERE t.is_valid='0' AND t.del_sign='0' ORDER BY t.award_date DESC");
//        StringBuilder sql = new StringBuilder("select t.id,t.erp_no,t.comp_name,t.host_org,GET_DIC('JygexinQcJb',t.award_level) as award_level,GET_DIC('JygexinQcDj',t.comp_rank) as comp_rank,t.get_title,t.award_date,DATE_FORMAT(t.award_date,'%Y-%m-%d %H:%i:%s') as award_date_str,u.`NAME` as user_name from t_contest_info t INNER JOIN t_dept_emp_rela d on t.erp_no=d.erp_no INNER JOIN (select * from t_org_dept o where o.path like ?) o2 on o2.id=d.dept_id LEFT JOIN isc_user u on t.erp_no=u.FAX WHERE t.is_valid='0' AND t.del_sign='0' ORDER BY t.award_date DESC");
//        StringBuilder sql = new StringBuilder("select t.id,t.erp_no,t.comp_name,t.host_org,GET_DIC('JygexinQcJb',t.award_level) as award_level,GET_DIC('JygexinQcDj',t.comp_rank) as comp_rank,t.get_title,t.award_date,u.`NAME` as user_name from t_contest_info t INNER JOIN t_dept_emp_rela d on t.erp_no=d.erp_no INNER JOIN (select * from t_org_dept o where o.path like ?) o2 on o2.id=d.dept_id LEFT JOIN isc_user u on t.erp_no=u.FAX WHERE t.is_valid='0' AND t.del_sign='0' ORDER BY t.award_date DESC");
        StringBuilder sql = new StringBuilder("select t.id,t.erp_no,t.comp_name,t.host_org,t.award_level,t.comp_rank,t.get_title,t.award_date,u.`NAME` as user_name from t_contest_info t INNER JOIN t_dept_emp_rela d on t.erp_no=d.erp_no INNER JOIN (select * from t_org_dept o where o.path like ?) o2 on o2.id=d.dept_id LEFT JOIN isc_user u on t.erp_no=u.FAX WHERE t.is_valid='0' AND t.del_sign='0' ORDER BY t.award_date DESC");
        params[0] = "%"+deptId+"%";
        return this.findAllBySQL(ContestInfoVo.class, sql.toString(), null, false, params);
    }
}
